<?php
defined('DB_DEBUG')             || define('DB_DEBUG', false);

define('DB_RET_RES',        'RES');
define('DB_RET_ROW',        'ROW');
define('DB_RET_ROWS',       'ROWS');
define('DB_RET_VALUE',      'VALUE');
define('DB_RET_ROWS_PAGE',  'ROWS_PAGE');

define('DB_DEFAULT_PAGE_SIZE', 2);


### data source ###############################################################
function &get_data_source($const_db, $param = null, $need_hash = true) 
{

    $hash        = ($param && $need_hash) ? md5($param) : null;
    $user        = null;
    $pass        = null;
    $port        = null;
    $table       = null;
    $table_alias = null;

    ###########################################################################
    switch ($const_db)
    {	
		case 'dod_config':
            $host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'dod_config';
            $table = $const_db;
            break;    
		case 'dod_pfbuy':
            $host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'dod_pfBuy';
            $table = $const_db;
            break; 
		case 'dod_pfBuyTemp':
            $host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'dod_pfBuyTemp';
            $table = $const_db;
            break; 
		case 'sdo_charge':
			$host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'sdo_charge';
            $table = $const_db;
            break; 
		case 'dodToolsDB':
			$host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'sdo_tools';
            $table = $const_db;
            break;
		case 'sdoMonitor':
			$host = '10.66.151.162';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'sdo_monitor';
            $table = $const_db;
			break;
		case 'sdoStatistic':
			$host = '10.66.152.124';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'sdo_statistic';
            $table = $const_db;
			break;
		case 'sdoStatAccount':
			$host = '10.66.151.162';
            $port = '3306';
            $user = 'root';
            $pass = 'appme2016wsdo';
            $database = 'sdo_apiaccountid';
            $table = $const_db;
			break;
		default :
			$ret = array();
			return $ret;
	}
    ###########################################################################

    $ret = array(   'host'          => $host.($port ? ":{$port}" : ''),
                    'user'          => is_null($user) ? "xxxx" : $user,
                    'pass'          => is_null($pass) ? "xxxx" : $pass,
                    'database'      => $database,
                    'table'         => $table,
                    'table_alias'   => $table_alias
                );
	//var_dump($ret);
    return $ret;
}
### end data source ###########################################################
?>
